package com.company.springhibernate.hibernatedaosupport.dao;

import java.util.Collection;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.company.modelo.Student;

public class HibernateStudentDao extends HibernateDaoSupport implements StudentDao {

	public Student getStudent(Integer id) {
		return (Student) getHibernateTemplate().get(Student.class, new Integer(id));
	}

	public List<Student> getAllStudents() {
		return getHibernateTemplate().find("from Student std order by std.lastName, std.firstName");
	}

	public List<Student> getGraduatedStudents() {
		return getHibernateTemplate().find("from Student std where std.status=1");
	}

	public List<Student> findStudents(String lastName) {
		return getHibernateTemplate().find("from Student std where std.lastName like ?", lastName + "%");
	}

	public void saveStudent(Student std) {
		getHibernateTemplate().saveOrUpdate(std);
	}

	public void removeStudent(Student std) {
		 getHibernateTemplate().delete(std);
	}

	
}
